﻿@{
    ViewBag.Title = "App病例设置";
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>App病历设置</title>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <link href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/ligerui-icons.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/Gray/css/all.css" rel="stylesheet" />
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <script>
        var manager;
        $(function () {
            initTable();
        });
        //加载列表
        function initTable() {
            $("#maingrid").ligerGrid({
                url: '/ChestPainCenter/AppCaseConfig/GetData?ram=' + Math.random(),
                columns: [
                    { display: 'App显示名称', name: 'Name', align: 'left', minWidth: 120, width: 200 },
                    { display: '表名', name: 'Table_Name', align: 'left', width: 200 },
                    { display: '字段', name: 'Column_Name', align: 'left', width: 200 },
                    { display: '归属', name: 'User_Control', align: 'left', width: 200 },
                    {
                        display: '是否启用', name: 'Status', minWidth: 40, width: 80, render: function (row) {
                            return row.Status == 1 ? "是" : "<span style='color:red;'>否</span>";
                        }
                    },
                    { display: '排序', name: 'Control_Order', minWidth: 40, width: 80, editor: { type: "string" } },
                    {
                        display: '操作', name: '', minWidth: 40, width: 80, render: function (rowdata, rowindex, value) {
                            var html = "";
                            if (rowdata.Status == 0) {
                                html += "<a href='javascript:ChangeStatus(" + rowdata.Id + ",1)'>启用</a> ";
                            } else {
                                html += "<a href='javascript:ChangeStatus(" + rowdata.Id + ",0)'>停用</a> ";
                            }
                            return html;
                        }
                    }
                ],
                onDblClickRow: function (data, rowindex, rowobj) {
                    EditData();
                },
                enabledEdit: true,
                usePager: false,
                rownumbers: true,
                height: '100%',
                heightDiff: 25
            });
        }
        function AddOrEdit(Id) {
            $.ligerDialog.open({
                height: 410,
                width: 450,
                title: '编辑质控项',
                url: '/ChestPainCenter/AppCaseConfig/AddOrEdit?Id=' + Id,
                showMax: false,
                showToggle: false,
                showMin: false,
                isResize: false,
                slide: false,
                buttons: [{
                    text: '回调函数', onclick: function (i, d) {
                        $("#btnSearch").click();
                    }
                }]
            });
            $(".l-dialog-buttons").hide();
        }
        //修改按钮
        function EditData() {
            var row = $("#maingrid").ligerGrid().getSelected();
            if (!row) {
                $.ligerDialog.warn("请选择要修改的数据！");
            } else {
                AddOrEdit(row.ID);
            }
        }
        //删除按钮
        function DelData() {
            var row = $("#maingrid").ligerGrid().getSelected();
            if (!row) {
                $.ligerDialog.warn("请选择要删除的数据！");
            } else {
                $.ligerDialog.confirm('数据删除不可恢复，确定要删除该数据吗？', function (yes) {
                    if (yes) {
                        ChangeStatus(row.Id, 2);
                    }
                })
            }
        }
        function ChangeStatus(Id, status) {
            var editurl = "/ChestPainCenter/AppCaseConfig/UpdateStatus";
            $.post(editurl, {
                rnd: new Date().getMilliseconds(),
                Status: status,
                Id: Id
            }, function (data) {
                $.ligerDialog.alert(data);
                window.location.reload(); //刷新页面
            })
        }
        function cancelEdit(rowid) {
            manager.cancelEdit(rowid);
        }
        function endEdit(rowid) {
            manager.endEdit(rowid);
        }
    </script>
</head>
<body>
    <div class="searchbar">
        <div class="sbligerButton">
            <input id="btnAdd" type="button" value="新增" onclick="AddOrEdit(0)" class="l-button" />
        </div>
        <div class="sbligerButton">
            <input id="btnModify" type="button" value="修改" onclick="EditData()" class="l-button" />
        </div>
        <div class="sbligerButton">
            <input id="btnDel" type="button" value="删除" onclick="DelData()" class="l-button" />
        </div>
    </div>
    <div id="maingrid"></div>
</body>
</html>

